#requests.get() 同步的代码 -》 异步操作aiohttp
'''
异步爬取图片
'''
# import aiohttp
# import asyncio
#
# urls = [
#     "http://kr.shanghai-jiuxin.com/file/2022/0406/67c3f1fa0e9ab06ac476e57bbe921432.jpg",
#     "http://kr.shanghai-jiuxin.com/file/2022/0406/2410d80601a7d093e933d8e15f4da9ee.jpg",
#     "http://kr.shanghai-jiuxin.com/file/2022/0406/ae23a3d14d0aa3086ad7b01c8b767dcd.jpg"
# ]
#
# async def aiodownload(url):
#     name = url.rsplit("/", 1)[1]
#     # s = aiohttp.ClientSession() #等价于request
#     async with aiohttp.ClientSession() as session:
#         async with session.get(url) as resp:
#             with open("./文件/" + name, mode="wb") as f:
#                 f.write(await resp.content.read()) #读取内容异步，需要挂起
#
# async def main():
#     tasks = []
#     for url in urls:
#         tasks.append(asyncio.create_task(aiodownload(url)))
#
#     await asyncio.wait(tasks)
#
# if __name__ == '__main__':
#     asyncio.run(main())

'''
异步爬取小说
'''

url = "https://boxnovel.baidu.com/boxnovel/wiseapi/chapterList?bookid=4306063500&pageNum=1&order=asc&site="

